using Furion.DatabaseAccessor;
using SqlSugar;

namespace Admin.NET.Application.Entity;

/// <summary>
/// 知识库表
/// </summary>
[SugarTable("knowledge_base", "知识库表")]
public class KnowledgeBase : EntityBaseDel
{
    /// <summary>
    /// 知识标题
    /// </summary>
    [SugarColumn(ColumnName = "title", ColumnDescription = "知识标题", Length = 256)]
    public string Title { get; set; }

    /// <summary>
    /// 知识内容
    /// </summary>
    [SugarColumn(ColumnName = "content", ColumnDescription = "知识内容", ColumnDataType = "text")]
    public string Content { get; set; }

    /// <summary>
    /// 知识分类
    /// </summary>
    [SugarColumn(ColumnName = "category", ColumnDescription = "知识分类", Length = 64)]
    public string Category { get; set; }

    /// <summary>
    /// 关键词
    /// </summary>
    [SugarColumn(ColumnName = "keywords", ColumnDescription = "关键词", Length = 512)]
    public string Keywords { get; set; }

    /// <summary>
    /// 文档类型
    /// </summary>
    [SugarColumn(ColumnName = "document_type", ColumnDescription = "文档类型", Length = 32)]
    public string DocumentType { get; set; } = "text";

    /// <summary>
    /// 文档来源
    /// </summary>
    [SugarColumn(ColumnName = "source", ColumnDescription = "文档来源", Length = 128)]
    public string Source { get; set; } = "系统内置";

    /// <summary>
    /// 文档URL
    /// </summary>
    [SugarColumn(ColumnName = "document_url", ColumnDescription = "文档URL", Length = 512, IsNullable = true)]
    public string? DocumentUrl { get; set; }

    /// <summary>
    /// 优先级
    /// </summary>
    [SugarColumn(ColumnName = "priority", ColumnDescription = "优先级")]
    public int Priority { get; set; } = 1;

    /// <summary>
    /// 是否启用
    /// </summary>
    [SugarColumn(ColumnName = "is_enabled", ColumnDescription = "是否启用")]
    public bool IsEnabled { get; set; } = true;

    /// <summary>
    /// 最后更新时间
    /// </summary>
    [SugarColumn(ColumnName = "last_updated", ColumnDescription = "最后更新时间")]
    public DateTime LastUpdated { get; set; } = DateTime.Now;

    /// <summary>
    /// 访问次数
    /// </summary>
    [SugarColumn(ColumnName = "access_count", ColumnDescription = "访问次数")]
    public int AccessCount { get; set; } = 0;

    /// <summary>
    /// 相似度分数
    /// </summary>
    [SugarColumn(ColumnName = "similarity_score", ColumnDescription = "相似度分数", IsNullable = true)]
    public float? SimilarityScore { get; set; }
}

/// <summary>
/// 知识向量表
/// </summary>
[SugarTable("knowledge_vector", "知识向量表")]

public class KnowledgeVector : EntityBaseDel
{
    /// <summary>
    /// 知识库ID
    /// </summary>
    [SugarColumn(ColumnName = "knowledge_id", ColumnDescription = "知识库ID")]
    public long KnowledgeId { get; set; }

    /// <summary>
    /// 向量数据（JSON格式）
    /// </summary>
    [SugarColumn(ColumnName = "vector", ColumnDescription = "向量数据", ColumnDataType = "longtext")]
    public string Vector { get; set; }

    /// <summary>
    /// 向量维度
    /// </summary>
    [SugarColumn(ColumnName = "dimension", ColumnDescription = "向量维度")]
    public int Dimension { get; set; } = 384;

    /// <summary>
    /// 向量模型
    /// </summary>
    [SugarColumn(ColumnName = "model", ColumnDescription = "向量模型", Length = 64)]
    public string Model { get; set; } = "text-embedding-ada-002";

    /// <summary>
    /// 创建时间
    /// </summary>
    [SugarColumn(ColumnName = "create_time", ColumnDescription = "创建时间")]
    public new DateTime CreateTime { get; set; } = DateTime.Now;
}

/// <summary>
/// 知识库分类表
/// </summary>
[SugarTable("knowledge_category", "知识库分类表")]

public class KnowledgeCategory : EntityBaseDel
{
    /// <summary>
    /// 分类名称
    /// </summary>
    [SugarColumn(ColumnName = "name", ColumnDescription = "分类名称", Length = 64)]
    public string Name { get; set; }

    /// <summary>
    /// 分类描述
    /// </summary>
    [SugarColumn(ColumnName = "description", ColumnDescription = "分类描述", Length = 256)]
    public string Description { get; set; }

    /// <summary>
    /// 父分类ID
    /// </summary>
    [SugarColumn(ColumnName = "parent_id", ColumnDescription = "父分类ID", IsNullable = true)]
    public long? ParentId { get; set; }

    /// <summary>
    /// 排序号
    /// </summary>
    [SugarColumn(ColumnName = "sort_order", ColumnDescription = "排序号")]
    public int SortOrder { get; set; } = 0;

    /// <summary>
    /// 是否启用
    /// </summary>
    [SugarColumn(ColumnName = "is_enabled", ColumnDescription = "是否启用")]
    public bool IsEnabled { get; set; } = true;
}
